<?php

class AddSlugColumn extends SMigration
{
    public function up()
    {
        $this->add_column('beers', 'slug', 'string', array('after' => 'nom'));
        SMapper::reset_meta_information('Beer');
        foreach (Beer::$objects->all() as $beer) {
            $beer->update_attribute('slug', SInflection::urlize($beer->nom));
        }
    }
    
    public function down()
    {
        $this->remove_column('beers', 'slug');
    }
}

?>
